﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisplayBoardInfo.Server.Session
{
    /// <summary>
    /// Abstract factory for creates message handlers
    /// </summary>
    public static class MessageHandlerFactory
    {
        /// <summary>
        /// Creates new message handler for specyfic message type.
        /// </summary>
        /// <param name="message">Network message to handle.</param>
        /// <returns>Message handler</returns>
        /// <exception cref="ArgumentOutOfRange">When message does not support</exception>
        public static MessageHandlers.MessageHandler Create(Network.Messages.NetworkMessage message)
        {
            switch (message.Type)
            { 
                case Network.Messages.NetworkMessageTypes.Users :
                    return new MessageHandlers.UsersHandler((Network.Messages.Content.User)message.Content);
                default :
                    throw new ArgumentOutOfRangeException("Type does not support.");
            }
        }
    }
}
